<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<body>
<h1>jianglai BBS</h1><br/>
<a href="/login/index.do">首页</a>
<c:if test="${user != null}">
    ${user.nickName}  <a href="/login/logout.do">登出</a>
</c:if>
<h1>${post.title}</h1><br>
用户： ${post.nickName} 创建时间: <fmt:formatDate value="${post.createDate}" pattern="yyyy-MM-dd"/>
<hr>
<p>${post.content}</p>
<br/>
<c:if test="${user==null}">
    <a href="/login/loginPage.do">登录并回复</a>
</c:if>
<c:if test="${user != null}">
    <form method="post" action="/post/reply/${post.id}">
        <textarea name="content"></textarea><input type="submit" value="回复"/>
    </form>
</c:if>

<c:forEach items="${subPost}" var="sp">
    用户： ${sp.nickName} 回复时间: <fmt:formatDate value="${sp.createDate}" pattern="yyyy-MM-dd hh:mm:ss"/>
    <hr>
    <p>${sp.content}</p>
</c:forEach>
</body>
</html>
